home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-25 | 6.4 KB | 307 lines | [TEXT/MSET] |
- false constant debug?
-
- file INPF
-
- : #ALIGN4 \ ( n -- n' )
- 3 + $ fffffffc and ;
-
-
- true -> case_in_names?
-
- : macConstant
- [ FALSE -> CASE_IN_NAMES? ]
- >in @
- defined?
- IF ['] inpf u> IF 2drop EXIT THEN
- ELSE drop
- THEN
- >in !
- constant
- ;
-
-
- (* ****
- I don't want to handle conditionals any more - I think we mightn't have the
- nesting 100% right, and anyway we do want to make the old routine names
- available - and likewise any other sort of alternative names.
-
- forward [IF]
-
- : gobble_conditional { \ level addr len -- }
- 1 -> level \ initial level count
- +echo \ let's see what we're skipping
- BEGIN
- Mword count -> len -> addr
- addr len " [IF]" s=
- IF 1 ++> level \ increment level count
- ELSE
- addr len " [THEN]" s=
- IF 1 --> level \ decrement level count
- level 0EXIT \ and if zero, we're done
- ELSE
- level 1 =
- IF \ at lev 1, we need to check for [ELSE] and [ELIF]
- addr len " [ELSE]" s= ?EXIT
- addr len " [ELIF]" s= ?EXIT \ there's only one, and it doesn't
- \ do anything
- THEN
- THEN
- THEN
- AGAIN
- ;
-
-
- :f [IF] NIF gobble_conditional -echo THEN ;f
- : [ELSE] gobble_conditional -echo ;
- : [THEN] ;
- : [ELIF] drop gobble_conditional -echo ;
-
- **** *)
-
- : [IF] drop ;
- : [ELSE] ;
- : [THEN] ;
- : [ELIF] drop ;
-
-
- true -> case_in_names?
-
- : macDefined? DEFINED? NIP ;
- : macStruct MWORD DROP ;
- : macUnion MWORD DROP ;
- : macField DROP MWORD DROP ;
- : macFiller 2DROP ;
- : macEnd-struct 2DROP ;
- : macEnd-union 2DROP ;
- : macSynonym MWORD DROP MWORD DROP ;
-
- : and AND ;
- : or OR ;
- : xor XOR ;
- : lshift LSHIFT ;
- : rshift RSHIFT ;
- : negate NEGATE ;
- : 'type POSTPONE 'TYPE ; IMMEDIATE
-
-
- FALSE -> CASE_IN_NAMES?
-
-
- string temp
-
- : READ_INLINE { \ loc svd svCaseFlg -- }
- case_in_names? -> svCaseFlg
- false -> case_in_names?
- clear: temp
- BEGIN
- >in @ src-len >=
- IF svCaseFlg -> case_in_names? EXIT
- THEN
- hex mword number decimal
- pad w! pad 2 add: temp
- AGAIN ;
-
-
- false value register_based?
- 0 value ^hndlr
-
- : 68k_parm_adjust { parm parm# parm? -- parm' }
- parm -1 =
- NIF
- parm $ ffff0000 and
- IF \ it's a register parm
- true -> register_based?
- $ D001 ^hndlr w!
- parm 16 >> EXIT
- THEN
- THEN
-
- parm? \ parm or result?
- IF \ parm
- register_based?
- IF ." warning - non-reg parm in reg-based call "
- latest name> .id cr
- THEN
- parm
- \ dup 1 and + \ &&& don't round length any more
- ELSE \ result
- parm IF
- register_based?
- IF ." warning - non-reg result in reg-based call "
- latest name> .id cr
- THEN
- THEN
- parm \ for results, we don't round so call
- THEN \ windup gets done properly.
- ;
-
-
- true -> case_in_names?
-
- : macExtern
-
- [ FALSE -> CASE_IN_NAMES? ]
-
- { \ #parms #cells ^PPCinfo ^68kInfo -- }
-
- 0 -> #cells false -> register_based?
- \ true -> case_in_names?
- >in @
- defined?
- IF ['] inpf u>
- IF drop \ drop >in - now TOS is # parms
- -1 DO 2drop LOOP \ drop parm info, also result info
- 0 -> src-len \ skip 68k inline code sequence
- \ false -> case_in_names?
- EXIT
- THEN
- ELSE drop
- THEN
-
- >in !
- create \ create the new dic entry (case sensitive)
- \ false -> case_in_names?
- DP 2- -> ^hndlr
- $ D000 ^hndlr w! \ dummy "handler code"
- DP -> ^PPCinfo 0 w, \ leave space for PPC info
-
- \ #parms
- dup -> #parms c, \ store # parms for 68k
- DP -> ^68kInfo
- #parms
- iF pad #parms n, \ reserve space for rest of 68k parm info
- #parms
- FOR
- \ #bytes in next PPC parm - convert to #cells and accumulate
- 3 + 2 >> ++> #cells
- \ 68k parm info
- i true 68k_parm_adjust \ check if reg-based and take care of it
- ^68kInfo i + c! \ store in right order in 68k info
- NEXT
- THEN
- #cells ^PPCinfo c! \ store # PPC parm cells at ^PPCinfo
-
- \ # result bytes
- 3 + 2 >> ^PPCinfo 1+ c! \ store # PPC result cells at ^PPCinfo+1
- 0 false 68k_parm_adjust c, \ store 68k info. We don't
- \ round here since we have to know whether
- \ and by how much to adjust by at the end
- \ of the call.
- align-dp
- read_inline
- reset: temp len: temp w, all: temp n,
-
- 0 -> src-len \ on the PPC we ignore the 68k inline code sequence
- ;
-
-
- : FIND_IN_CALLSMOD \ ( s255 \ svCaseFlg -- cfa true | -- s255 false )
- find: callsMod
- ;
-
-
- : myHeader
- PPC? IF ppc_header ELSE header THEN ;
-
-
- : KONST { \ svCaseFlg -- konst }
- case_in_names? -> svCaseFlg
- true -> case_in_names?
- ['] find_in_callsMod -> extraFind
- '
- svCaseFlg -> case_in_names?
- 0 -> extraFind
- dup 2- w@x -4 <> abort" not a konst!"
- @ postpone lit
- ; immediate
-
-
- : $>KONST { addr len \ svCaseFlg -- konst }
- case_in_names? -> svCaseFlg
- true -> case_in_names?
- ['] find_in_callsMod -> extraFind
- addr len sFind
- svCaseFlg -> case_in_names?
- 0 -> extraFind
- NIF abort" konst not defined" THEN
- dup 2- w@x -4 <> abort" not a konst!"
- @
- ;
-
-
- : SYSCALL { \ svCaseFlg sv-in addr #parms
- #parm_cells #res_cells
- len ^len-byte name_len -- }
- ?exec
- >in @ -> sv-in
-
- \ first, is it actually a call?
-
- case_in_names? -> svCaseFlg
- true -> case_in_names?
- ['] find_in_callsMod -> extraFind
- mword find NIF 150 die THEN \ "can't find call for this name"
- 0 -> extraFind svCaseFlg -> case_in_names?
- -> addr
- addr 2- w@
- dup 1 and -> register_based?
- -2 and $ D000 <> abort" not a call!"
-
- \ now, if we've already defined it as a sysCall for the same processor?
- \ If so, we don't need to do it again.
-
- sv-in >in !
- defined?
- IF 2- w@x
- CASE[ -120 ], [ -122 ]=> PPC? 0EXIT
- [ $ BF01 ]=> PPC? ?EXIT
- DEFAULT=> drop
- ]CASE
- ELSE
- drop
- THEN
-
- sv-in >in !
-
- PPC?
- IF myHeader $ BF01 codeW,
- addr c@ -> #parm_cells
- addr 1+ c@ -> #res_cells
- #res_cells codeC, #parm_cells codeC,
- nilP code,
- addr >name n>count dup -> name_len
- CDP place
- name_len 2+ #align4 ++> CDP
- ELSE
- header
- register_based? IF -122 ELSE -120 THEN
- w, \ sysCall_h handler for 68k
- 2 ++> addr \ look at 68k parm info
- addr c@ -> #parms
- DP -> ^len-byte 0 c, \ total length of call info will go here
- #parms c,
- 1 ++> addr
- #parms 1+ FOR \ add 1 since we're including the result byte
- addr c@ c, 1 ++> addr
- NEXT
- addr 1 and ++> addr
- 1 or> DP \ put DP to odd bdry since we'll be omitting
- \ the length byte
- addr length n, \ move inline code over
- DP ^len-byte - 1-
- ^len-byte c! \ and store length of call info (excluding length byte)
- THEN
- ;
-
-
- new: temp
-
- true -> case_in_names?
- // xcalls
- FALSE -> CASE_IN_NAMES?
-
- release: temp
-
- cr .( Dic room at end of compiling callsMod: ) room . cr
-
-